/*
 * RemovePlaceCommand.java
 *
 * Created on 7 czerwiec 2007, 13:57
 */

package edu.uj.petri.commands;

import edu.uj.petri.document.Document;
import edu.uj.petri.view.PlaceView;
import edu.uj.petri.view.View;
import java.util.ResourceBundle;

/**
 *
 * @author Paweł
 */
public class RemovePlaceCommand extends Command {
    
    private PlaceView placeView;
    private Memento memento;
    
    /** Creates a new instance of RemovePlaceCommand */
    public RemovePlaceCommand( PlaceView placeView ) {
        
        this.placeView = placeView;
    }

    public String toString() {
        String retval = ResourceBundle.getBundle("edu/uj/petri/messages").getString("usun_miejsce");
        if (placeView != null) {
            retval += " " + placeView.getNode().getName();
        }
        return retval;
    }

    void execute() {
        
        memento = placeView.getMemento();
        placeView.removeFrom( Document.getActiveDocument().getView());
    }

    void undo() {
        
        placeView.applyMemento(memento);
        View view = Document.getActiveDocument().getView();
        view.addElement(placeView);
        view.draw();
    }

    boolean canBeCombined(Command c) {
        
        return false;
    }
    
    private static final long serialVersionUID = 27474258596028958L;    

}
